import type {
  CalculationIndicatorRecalculationBatchIndicatorRecalculationParams as A,
  AjaxPagingResult,
  CalculationIndicatorRecalculationSelectCalculationIndicatorPageParams as B,
  CalculationIndicatorRecalculationSelectRecalculationScheduleDetailPageParams as C,
  CalculationIndicatorRecalculationSelectRecalculationSchedulePageParams as D,
  CalculationIndicatorRecalculationSelectRecalculationSchedulePageResult as E,
  CalculationIndicatorRecalculationSelectRecalculationScheduleDetailPageResult as F,
  IndicatorInfo,
} from '@/types'

const controller = getAjaxBaseUrl(
  '/calculationIndicatorRecalculation',
  '/compute',
)

/** 批量指标重算 */
export function batchIndicatorRecalculation(params: A[]) {
  return post(`${controller}/batchIndicatorRecalculation`, params)
}

/** 根据时间类型分页查询统计指标 */
export function selectCalculationIndicatorPage(params: B) {
  return post<AjaxPagingResult<IndicatorInfo[]>>(
    `${controller}/selectCalculationIndicatorPage`,
    params,
  )
}

/** 分页查询重算任务明细 */
export function selectRecalculationScheduleDetailPage(params: C) {
  return post<AjaxPagingResult<F[]>>(
    `${controller}/selectRecalculationScheduleDetailPage`,
    params,
  )
}

/** 分页查询重算进度 */
export function selectRecalculationSchedulePage(params: D) {
  return post<AjaxPagingResult<E[]>>(
    `${controller}/selectRecalculationSchedulePage`,
    params,
  )
}

/** 根据指标编码查询存储类型对应的公式内容 */
export function selectFormulaContentByIndicatorNumber(indicatorNumber: string) {
  return get<
    Record<string, { type: number, formulaContent: string }>
  >(`${controller}/selectFormulaContentByIndicatorNumber`, {
    indicatorNumber,
  })
}

/** 停止重算任务信息 */
export function stopBaseDataJob(id: number) {
  return get(`${controller}/stopBaseDataJob`, { id })
}
